<template>
    <div class="container">
        <m-header :title="headerTitle" :show="showBack"  @back="clickBack"></m-header>
        <div class="body">
            <div class="title">
                登录页面
            </div>
            <div class="item">
                <div class="item-l"> 用户名：</div>
                <div class="item-r">
                    <cube-input  v-model="username" :clearable="clearable"></cube-input>
                </div>
            </div>
            <div class="item">
                <div class="item-l"> 密码：</div>
                <div class="item-r">
                    <cube-input v-model="pwd" :type="type" :eye="eye"></cube-input>
                </div>
            </div>
            <cube-button class="submit" @click="userLogin">登录</cube-button>

            <cube-button style="margin-top:20px" @click="userLogout">退出</cube-button>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
import MHeader from "base/m-header/m-header";

import {login,logout} from 'api/api'
export default {
  data() {
    return {
      username: "ds",
      pwd: "123",



      headerTitle:'登录',
      showBack:true,
      clearable: true,

      type: "password",
      eye: {
        open: false,
        reverse: true
      }
    };
  },
  methods:{
      clickBack() {
          this.$router.back()
      },
      
      userLogin() {
          let data ={
              username:this.username,
              pwd:this.pwd
          }
          console.log(data)
          login(data).then(res=>{
              console.log('接盘登录反馈',res)   
          })
      },

      userLogout() {
          logout().then(res=>{
              console.log('接盘退出反馈',res)
          })
      }
  },
  components: {
    MHeader
  }
};
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
.container {
    position: fixed;
    width: 100%;
    top: 0;
    bottom: 0;
    z-index: 100;
    background: #fff;

    .body {
        position: absolute;
        top: 44px;
        width: 100%;
        bottom: 0;
        box-sizing: border-box;
        padding: 100px 20px 0 20px;

        .title {
            font-size: 40px;
            font-weight: bold;
            text-align: left;
            margin-bottom: 50px;
        }

        .item {
            margin-bottom 10px
            display: flex;
            height: 44px;
            align-items: center;

            .item-l {
                width: 80px;
                text-align: left;
            }

            .item-r {
                flex: 1;
            }
        }

    
    }
}
</style>
